import React, { Component } from 'react'

export default class From extends Component {

    state ={
        name:'张三',
        age: 9
    }

    handleInput=()=>{
        this.refs.myTnput.focus() 
    }
    changeInput=(h, e)=>{
        // console.log(e.target)
        // this.setState({[h]:e.target.value})
        this.refs.Tnput
        console.log(e.target.value)
    }
  render() {
    return (
      <div>
        <label>姓名：<input ref="Tnput"type="text" onChange={this.changeInput.bind(null, 'name')} /></label>
        <label>年龄：<input type="text" onChange={this.changeInput.bind(null, 'age')} /></label>
        <button onClick={this.handleInput}>my btn</button>

        <hr/>

        <label>姓名：<input type="text" ref="myTnput"/></label>
        <label>年龄：<input type="text" ref="myTnput"/></label>
        <button onClick={this.handleInput}>my btn</button>
      </div>
    )
  }
}
